#!/bin/bash
set -e
set -u
#
# Run a simple backup
#   then restore it.
#
TestName="$(basename "$(pwd)")"
export TestName

#shellcheck source=../environment.in
. ./environment

#shellcheck source=../scripts/functions
. "${rscripts}"/functions
"${rscripts}"/cleanup
"${rscripts}"/setup

invoke_dir() {
  options=("$@")
  if [ -n "${SUSAN_DIRECTOR_USER:-}" ]; then
    options+=(-u "${SUSAN_DIRECTOR_USER}")
  fi
  if [ -n "${SUSAN_DIRECTOR_GROUP:-}" ]; then
    options+=(-g "${SUSAN_DIRECTOR_GROUP}")
  fi
  if [ -n "${SUSAN_CONFIG_DIR:-}" ]; then
    options+=(-c "${SUSAN_CONFIG_DIR}")
  fi
  "${SUSAN_DIRECTOR_BINARY}" "${options[@]}"
}


start_test

# check for deprecated database if applicable
if [ "$DBTYPE" = mysql -o "$DBTYPE" = sqlite3 ]; then
  invoke_dir -t -v 2>&1 \
    | grep "Deprecated DB driver ${DBTYPE} for Catalog MyCatalog"
fi

end_test
